package com.skyline.wo.dao;

import java.util.List;

import com.skyline.common.bean.Page;
import com.skyline.wo.model.Article;

/**
 * ArticleDao is the interface of Article DATABASE ACCESS operation
 * 
 * @author Jairus Chan
 * @version 0.1
 * 
 */
public interface ArticleDao {

	/**
	 * insert article record to the db;
	 * 
	 * @param authority
	 *            the read authority of this article
	 * @param ownerId
	 *            the id of this article's owner
	 * @param onwerPortriat
	 *            this portrait URL of this article's owner
	 * @param ownerNickname
	 *            the nickname of this article's owner
	 * @param title
	 *            article's title
	 * @param content
	 *            article's content
	 * @param categoryId
	 *            the name of category which this article is belong to
	 * @param categoryName
	 * 
	 * @return null
	 */
	public long insertArticle(Integer authority, Long ownerId, String ownerPortrait, String ownerNickname,
			String title, String content, String digest, Long categoryId, String categoryName);

	/**
	 * update article
	 * 
	 * @param authority
	 *            the read authority of this article
	 * @param ownerId
	 *            the id of this article's owner
	 * @param title
	 *            article's title
	 * @param content
	 *            article's content
	 * @param categoryId
	 *            the name of category which this article is belong to
	 * @param categoryName
	 * 
	 * @return null
	 */
	public void updateArticle(Long id, Integer authority, Long ownerId, String title, String content, String digest,
			Long categoryId, String categoryName);

	/**
	 * updateArticleAutyOrCateg() is used to update the authority or category
	 * which this article is belong to
	 * 
	 * @param id
	 *            the id of the article
	 * @param authority
	 *            the read authority of this article
	 * @param categoryId
	 *            this article's category
	 * @param categoryName
	 * 
	 * @return null
	 */
	public void updateArticleAutyOrCateg(Integer id, Integer authority, Long categoryId, String categoryName);

	/**
	 * updateArticleContent() is used to update the content of this article
	 * 
	 * @param id
	 *            the id of the article
	 * @param authority
	 *            the read authority of this article
	 * @param ownerId
	 *            the id of this article's owner
	 * @param onwerPortriat
	 *            this portrait URL of this article's owner
	 * @param ownerNickname
	 *            the nickname of this article's owner
	 * @param title
	 *            article's title
	 * @param content
	 *            article's content
	 * @param categoryId
	 *            the name of category which this article is belong to
	 * @param categoryName
	 * 
	 * @return null
	 */
	public void updateArticleContent(Integer id, Integer authority, String ownerPortrait, String ownerNickname,
			String title, String content, Long categoryId, String categoryName);

	/**
	 * query article by ownerId
	 * 
	 * @param page
	 *            the param page is used to pagination
	 * @param ownerId
	 *            the id of this article's owner
	 * @param authority
	 *            the read authority of this user own
	 * @return List<Article> the query result is a list
	 */
	public List<Article> queryArticleByOwnerId(Page page, Long ownerId, Integer authority);

	/**
	 * query article by categoryId
	 * 
	 * @param page
	 *            the param page is used to pagination
	 * @param categoryId
	 *            the id of this article's category
	 * @param authority
	 *            the read authority of this user own
	 * @return List<Article> the query result is a list
	 */
	public List<Article> queryArticleByCategoryId(Page page, Long categoryId, Long ownerId, Integer authority);

	/**
	 * query article by id
	 * 
	 * @param id
	 *            the id of this article
	 * @return List<Article> the query result is a list
	 */
	public Article queryArticleById(Long id);
	
	/**
	 * get prior article
	 * @param id
	 * the id of current article
	 * @param authority
	 * the read authority of this user
	 */
	public Article queryPriorArticleById(Long categoryId,Long id,Integer authority);
	
	/**
	 * get prior article
	 * @param id
	 * the id of current article
	 * @param authority
	 * the read authority of this user
	 */
	public Article queryNextArticleById(Long categoryId,Long id,Integer authority);
	
	/**
	 * delete article
	 * 
	 * @param id
	 *            the id of this article
	 * @param actionerId
	 *            the id of the actioner
	 * @return null
	 */
	public void deleteArticle(Long id, Long actionerId);

	/**
	 * updateArticleVisitNum add 1 to the read num of this article where someone
	 * has read it
	 * 
	 * @param id
	 *            the id of this article
	 * @return null
	 */
	public void updateArticleVisitNum(Long id);

}
